// pages/my/my.js
import Dialog from '@vant/weapp/dialog/dialog';
Page({

  onShow(){
     let userid=wx.getStorageSync('id');
     if(userid){
       console.log("登录成功")
     }else{
       console.log("没有登录")
       Dialog.confirm({
        title: '标题',
        message: '弹窗内容',
      })
        .then(() => {
          // on confirm
          wx.login({
            success:(res)=>{
              console.log(res.code)
              wx.request({
                url: `http://192.168.0.111/login/wechatLogin/${res.code}`,
                method:"post",
                success:(data)=>{
                  console.log("cg",data)
                }
              })
            }
          })
        })
        .catch(() => {
          this.goHome()
          // on cancel
        });
     }
  },
  goHome(){
    wx.switchTab({
      url: '/pages/index/index',
    })
  }
})